{% extends "includes/forms.html" %}

{% macro supported_syntax_link(settings) %}
<p class="syntax-support">
  <a href="{{ settings.EXTENSION_WORKSHOP_URL }}/documentation/develop/create-an-appealing-listing/#make-use-of-markdown" target="_blank" rel="noopener noreferrer">{{ _('Some Markdown supported.') }}</a>
</p>
{% endmacro %}


{% macro empty_unless(truthy) %}
  {% if truthy %}
    {{ caller() }}
  {% else %}
    <span class="empty">{{ _('None') }}</span>
  {% endif %}
{% endmacro %}

{% macro flags(text, element, editable, alt_text=False) %}
  {% if editable %}
    <div>
      {{ element }}
      {{ element.errors }}
      <label for="id_{{ element.html_name }}">{{ text }}</label>
    </div>
  {% elif element %}
    {{ text }}
  {% elif alt_text %}
    {# This is what's shown if the element is false #}
    {# Defaults to nothing #}
    {{ alt_text }}
  {% endif %}
{% endmacro %}

{% macro compat(form, is_extra_form=False) %}
  <tr{% if is_extra_form %} class="app-extra-orig{{ ' app-extra' if not form.errors }}"{% endif %}>
    <td class="app {{ form.app.short }}">{{ form.app.pretty }}</td>
    <td class="select">
      <div>
        <label>{{ form.min.label }}</label> {{ form.min }}
        {{ form.min.errors }}
      </div>
      <div><span class="range">&ndash;</span></div>
      <div>
        <label>{{ form.max.label }}</label> {{ form.max }}
        {{ form.max.errors }}
      </div>
      {{ form.non_field_errors() }}
    </td>
    <td class="remove">
      <div>
        {{ form.application }}
        {{ form.id }}
        {% if form.DELETE %}
          <label>{{ form.DELETE.label }} {{ form.DELETE }}</label>
          <a href="#" class="remove" title="{{ _('Remove this application') }}">x</a>
        {% endif %}
      </div>
    </td>
  </tr>
{% endmacro %}

{% macro select_cats(form) %}
  <div class="addon-app-cats">
    <label>
      {# L10n: {0} is the maximum number of add-on categories allowed #}
      {{ ngettext('Select a category for this add-on:',
                  'Select <b>up to {0}</b> categories for this add-on:',
                  form.max_categories)|format_html(form.max_categories) }}
    </label>
    {{ form.categories }}
    {{ form.categories.errors }}
  </div>
{% endmacro %}
